﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CCUiMlmStepSizeDlg
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.ComponentModel;
using System.Drawing;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands;

public class CCUiMlmStepSizeDlg : TxForm
{
  private const string _STRING_TABLE_LOCATION = "DnProcessSimulateCommands.MultipleLocationsManipulation.MlmStringTable";
  private CCUiMlmMultipleLocationsManipulationDlg _creator;
  private StepType _stepType;
  private IContainer components;
  private Label lblStepTitle;
  private TextBox tbStepSize;
  private Button btnOK;
  private Button btnCancel;

  public CCUiMlmStepSizeDlg(CCUiMlmMultipleLocationsManipulationDlg creator, StepType stepType)
  {
    this.InitializeComponent();
    switch (stepType)
    {
      case StepType.Translation:
        this.lblStepTitle.Text = $"Translation step ({TxApplication.Options.Units.LinearUnitName}):";
        this.tbStepSize.Text = creator.TranslateStepValue.ToString("F" + TxApplication.Options.Units.LinearDigitsAfterDecimalPoint.ToString());
        break;
      case StepType.Rotation:
        this.lblStepTitle.Text = $"Rotation step ({TxApplication.Options.Units.AngularUnitName}):";
        this.tbStepSize.Text = creator.RotateStepValue.ToString("F" + TxApplication.Options.Units.AngularDigitsAfterDecimalPoint.ToString());
        break;
    }
    this._creator = creator;
    this._stepType = stepType;
  }

  private void btnCancel_Click(object sender, EventArgs e) => ((Form) this).Close();

  private void btnOK_Click(object sender, EventArgs e)
  {
    try
    {
      switch (this._stepType)
      {
        case StepType.Translation:
          this._creator.TranslateStepValue = double.Parse(this.tbStepSize.Text);
          break;
        case StepType.Rotation:
          this._creator.RotateStepValue = double.Parse(this.tbStepSize.Text);
          break;
      }
      ResourceManager resourceManager = new ResourceManager("DnProcessSimulateCommands.MultipleLocationsManipulation.MlmStringTable", ((object) this).GetType().Assembly);
      string str1 = resourceManager.GetString("REGISTRY_TRANSLATION_VALUE");
      string str2 = resourceManager.GetString("REGISTRY_ROTATION_VALUE");
      double num1 = this._creator.TranslateStepValue * TxApplication.Options.Units.LinearMultiplier;
      TxFormSettings.StoreFormValue((Form) this._creator, str1, (object) num1.ToString());
      double num2 = this._creator.RotateStepValue * TxApplication.Options.Units.AngularMultiplier;
      TxFormSettings.StoreFormValue((Form) this._creator, str2, (object) num2.ToString());
    }
    catch (Exception ex)
    {
    }
    ((Form) this).Close();
  }

  private void tbStepSize_Leave(object sender, EventArgs e)
  {
    double result = 0.0;
    if (!double.TryParse(this.tbStepSize.Text, out result))
    {
      this.tbStepSize.Undo();
    }
    else
    {
      int num = 0;
      if (this._stepType == StepType.Translation)
        num = TxApplication.Options.Units.LinearDigitsAfterDecimalPoint;
      else if (this._stepType == StepType.Rotation)
        num = TxApplication.Options.Units.AngularDigitsAfterDecimalPoint;
      this.tbStepSize.Text = result.ToString("F" + num.ToString());
    }
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CCUiMlmStepSizeDlg));
    this.lblStepTitle = new Label();
    this.tbStepSize = new TextBox();
    this.btnOK = new Button();
    this.btnCancel = new Button();
    ((Control) this).SuspendLayout();
    componentResourceManager.ApplyResources((object) this.lblStepTitle, "lblStepTitle");
    this.lblStepTitle.MaximumSize = new Size(139, 0);
    this.lblStepTitle.Name = "lblStepTitle";
    componentResourceManager.ApplyResources((object) this.tbStepSize, "tbStepSize");
    this.tbStepSize.Name = "tbStepSize";
    this.tbStepSize.Leave += new EventHandler(this.tbStepSize_Leave);
    componentResourceManager.ApplyResources((object) this.btnOK, "btnOK");
    this.btnOK.Name = "btnOK";
    this.btnOK.UseVisualStyleBackColor = true;
    this.btnOK.Click += new EventHandler(this.btnOK_Click);
    componentResourceManager.ApplyResources((object) this.btnCancel, "btnCancel");
    this.btnCancel.Name = "btnCancel";
    this.btnCancel.UseVisualStyleBackColor = true;
    this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
    componentResourceManager.ApplyResources((object) this, "$this");
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Control) this).Controls.Add((Control) this.btnCancel);
    ((Control) this).Controls.Add((Control) this.btnOK);
    ((Control) this).Controls.Add((Control) this.tbStepSize);
    ((Control) this).Controls.Add((Control) this.lblStepTitle);
    ((Form) this).FormBorderStyle = FormBorderStyle.FixedDialog;
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CCUiMlmStepSizeDlg);
    ((Form) this).ShowIcon = false;
    ((Control) this).ResumeLayout(false);
    ((Control) this).PerformLayout();
  }
}
